﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace FortuneHeavenCommon.ComMethod
{
    public class GenerateChargeCode
    {
        public static string Generate(int count,string first3)
        {
            Guid guid = Guid.NewGuid();
            string k = guid.ToString().Replace("-", "");
            string output = "";
            if (first3!=null)
	        output += first3;
            else
            for (int index = 0; index < 2; index++)
            {
                int f = ((int)k[index] - 48) % 10;
                output += f.ToString();
            }
            for (int index = 4; index < 9; index++)
            {
                int f = ((int)k[index] - 48) % 10;
                output += f.ToString();
            }

            for (int index = 16; index < 21; index++)
            {
                int f = ((int)k[index] - 48) % 10;
                output += f.ToString();
            }
            string add = "";
   
            output = output.Insert(4, add);
            string last10 = output.Substring(8);
            last10 = FortuneHeavenCommon.ComMethod.CommonEncrypt.Encrypt(last10).Substring(0, 10);
            output = output.Insert(9, last10);
            return output.Substring(0,19);

        }
    }
}
